package cn.wolfcode.ssm.service.impl;

import cn.wolfcode.ssm.domain.Hero;
import cn.wolfcode.ssm.mapper.HeroMapper;
import cn.wolfcode.ssm.query.HeroQueryObject;
import cn.wolfcode.ssm.query.PageResult;
import cn.wolfcode.ssm.service.IHeroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HeroServiceImpl implements IHeroService {
    @Autowired
    private HeroMapper heroMapper;
    @Override
    public void insert(Hero hero) {
        heroMapper.insert(hero);
    }

    @Override
    public void delete(Long id) {
        heroMapper.delete(id);
    }

    @Override
    public void update(Hero hero) {
        heroMapper.update(hero);
    }

    @Override
    public Hero selectOne(Long id) {
        return heroMapper.selectOne(id);
    }

    @Override
    public List<Hero> selectAll() {

        return heroMapper.selectAll();
    }

    @Override
    public PageResult queryForList(HeroQueryObject qo) {
        List<Hero> heroes = heroMapper.queryForList(qo);
        PageResult pageResult = new PageResult();
        pageResult.setList(heroes);
        return pageResult;
    }
}
